<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="姓名">
              <j-input placeholder="请输入员工姓名" v-model="queryParam.name"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpCompanyFiles:add')">新增</a-button>
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('公司档案')" :disabled="isDisabledAuth('erpCompanyFiles:export')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpCompanyFiles:import')">导入</a-button>
      </a-upload> -->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12" :key="index"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style="iconStyle"/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :customRow="customRow"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">

          <template v-if="record.auditStatus==0">
            <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="edit"
              @click="handleEdit(record)"
              :disabled="isDisabledAuth('erpCompanyFiles:edit')"
            />
            <!-- <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="delete"
              :disabled="isDisabledAuth('erpCompanyFiles:delete')"
            />
          </a-popconfirm> -->
            <a-divider type="vertical"/>
            <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(record.id)">
              <a-button type="primary" size="small" :disabled="isDisabledAuth('erpCompanyFiles:submit')">提交</a-button>
            </a-popconfirm>
          </template>
          <template v-if="record.auditStatus==1">
            <a-button type="primary" size="small" @click="handleAudit(record.id)" :disabled="isDisabledAuth('erpCompanyFiles:audit')">审核</a-button>
          </template>
          <template v-if="record.auditStatus==2">
            <a-popconfirm title="确定反审吗?" @confirm="() => handleCounterTrial(record.id)">
              <a-button type="primary" size="small" :disabled="isDisabledAuth('erpCompanyFiles:counterTrial')">反审</a-button>
            </a-popconfirm>
          </template>
        </span>

      </a-table>
    </div>

    <ErpCertificatePersonnelModal ref="modalForm" @ok="modalFormOk"></ErpCertificatePersonnelModal>
    <audit-modal ref="auditModal" @ok="modalFormOk"></audit-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ErpCertificatePersonnelModal from './modules/ErpCertificatePersonnelModal'
  import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

  export default {
    name: 'ErpCertificatePersonnelList',
    mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      ErpCertificatePersonnelModal
    },
    data () {
      return {
        description: '外聘员工档案页面',
        // 表头
        columns: [],
        // 列设置
        settingColumns: [],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '人员编号',
            align: 'center',
            width: 200,
            dataIndex: 'externalNo',
            ellipsis: true
          },
          {
            title: '姓名',
            align: 'center',
            width: 100,
            dataIndex: 'name',
            ellipsis: true
          },
          {
            title: '性别',
            align: 'center',
            width: 80,
            dataIndex: 'gender_dictText',
            ellipsis: true
          },
          {
            title: '身份证号',
            align: 'center',
            width: 200,
            dataIndex: 'idCardNo',
            ellipsis: true
          },
          {
            title: '身份证到期日',
            align: 'center',
            width: 100,
            dataIndex: 'idCardNoDue',
            ellipsis: true
          },
          {
            title: '学历',
            align: 'center',
            width: 100,
            dataIndex: 'highestDegree_dictText',
            ellipsis: true
          },
          {
            title: '所学专业',
            align: 'center',
            width: 200,
            dataIndex: 'major',
            ellipsis: true
          },
          {
            title: '所属团队',
            align: 'center',
            width: 200,
            dataIndex: 'teamId_dictText',
            ellipsis: true
          },
          {
            title: '合同有效期',
            align: 'center',
            width: 100,
            dataIndex: 'contractLife',
            ellipsis: true
          },
          {
            title: '参保单位',
            align: 'center',
            width: 300,
            dataIndex: 'insuredUnit_dictText',
            ellipsis: true
          },
          {
            title: '关系状态',
            align: 'center',
            width: 100,
            dataIndex: 'relationshipState_dictText',
            ellipsis: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 150,
            scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action' }
          }
        ],
        url: {
          list: '/api/erp/files/employee/erpEmployeeExternalFile/list',
          delete: '/api/erp/files/employee/erpEmployeeExternalFile/delete',
          deleteBatch: '/api/erp/files/employee/erpEmployeeExternalFile/deleteBatch',
          exportXlsUrl: '/api/erp/files/employee/erpEmployeeExternalFile/exportXls',
          importExcelUrl: 'api/erp/files/employee/erpEmployeeExternalFile/importExcel',
          submit: '/api/erp/files/employee/erpEmployeeExternalFile/submit',
          submitBatch: '/api/erp/files/employee/erpEmployeeExternalFile/submitBatch',
          revoke: '/api/erp/files/employee/erpEmployeeExternalFile/revoke',
          revokeBatch: '/api/erp/files/employee/erpEmployeeExternalFile/revokeBatch',
          counterTrial: '/api/erp/files/employee/erpEmployeeExternalFile/counterTrial',
          counterTrialBatch: '/api/erp/files/employee/erpEmployeeExternalFile/counterTrialBatch',
          audit: '/api/erp/files/employee/erpEmployeeExternalFile/audit',
          auditBatch: '/api/erp/files/employee/erpEmployeeExternalFile/auditBatch',
          overrule: '/api/erp/files/employee/erpEmployeeExternalFile/overrule',
          overruleBatch: '/api/erp/files/employee/erpEmployeeExternalFile/overruleBatch'
        },
        dictOptions: {},
        superFieldList: []
      }
    },
    created() {

    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig() {
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
